﻿@model RotaractProjectCalendar.ViewModels.ProjectIndexData

@{
    ViewBag.Title = "Projekty";
}

<h2>Projekty</h2>

<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Projects.FirstOrDefault().StartDateTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Projects.FirstOrDefault().ProjectTitle)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Projects.FirstOrDefault().Club.ClubTitle)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Projects.FirstOrDefault().Location)
        </th>
        <th></th>
    </tr>

    @foreach(var item in Model.Projects)
    {
        var selectedRow = "";
        if(item.Id == ViewBag.InstructorID)
        {
            selectedRow = "success";
        }
        <tr class="@selectedRow">
            <td>
                @Html.DisplayFor(modelItem => item.StartDateTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ProjectTitle)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Club.ClubTitle)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Location)
            </td>
            @Html.HiddenFor(model => model.Coordinator)
            <td>
                @Html.ActionLink("Wybierz", "Index", new { id = item.Id }) |
                @Html.ActionLink("Edytuj", "Details", new { id = item.Id }) |
                @Html.ActionLink("Usuń", "Delete", new { id = item.Id })
            </td>
        </tr>
    }
</table>

@if(Model.Club != null)
{
    <h3>Organizatorem wydarzenia jest:</h3>

    <table class="table">
        <tr>
            <th></th>
            <th></th>
            <th>
                @Html.DisplayNameFor(model => model.Club.ClubTitle)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Club.FbProfileAddress)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Club.WwwWebsiteAddress)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Club.ClubEmailAddress)
            </th>
        </tr>
        <tr>
            <td>
                @Html.ActionLink("Wybierz", "Index", new { ClubId = Model.Club.Id })
            </td>
            <td>
                <img src="@Url.Content(Model.Club.Logo)" class="img-circle img-responsive" alt="Club logo" width="300" />
            </td>
            <td>
                @Model.Club.ClubTitle
            </td>
            <td>
                <a href="@Model.Club.FbProfileAddress">Facebook</a>
            </td>
            <td>
                <a href="@Model.Club.WwwWebsiteAddress">Web page</a>
            </td>
            <td>
                @Model.Club.ClubEmailAddress
            </td>
        </tr>

    </table>
}

@if(Model.Coordinator != null && Request.IsAuthenticated)
{
    <h3>Koordynatorem projektu jest:</h3>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Coordinator.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Coordinator.PhoneNumber)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Coordinator.CoordinatorEmailAddress)
            </th>
        </tr>
        <tr>
            <td>
                @Model.Coordinator.Name
            </td>
            <td>
                @Model.Coordinator.PhoneNumber
            </td>
            <td>
                @Model.Coordinator.CoordinatorEmailAddress
            </td>
        </tr>
    </table>
}